package com.itheima.service;

import com.itheima.config.SpringConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * @author Xiao
 * @date 2021/9/13
 */
//1. 使用Spring整合Junit专用的类加载器
@RunWith(SpringJUnit4ClassRunner.class)
//2. 加载配置类
@ContextConfiguration(classes = {SpringConfig.class})
public class testForResourceService {
    @Autowired
    private ResourceService resourceService;
    @Test
    public void testOpenURL(){
        //注意：如果在Spring核心配置类中读取了MybatisConfig配置类，会去dao层接口上寻找对应sql语句，没有就会抛异常。
        //解决：
        // 1. 将SpringConfig.class上面的@Import注解里面的MybatisConfig.class注释掉
        // 2. 将AccountDao自动注入相关的@Autowired注释掉
        boolean result = resourceService.openURL(
                "https://www.baidu.com?name=haha", "root ");
        System.out.println(result);
    }
}
